package com.huaxia.util;


import com.huaxia.pojo.SalesData;
import com.huaxia.pojo.attend.BranchAttend;
import com.huaxia.pojo.attend.BranchLayerAttend;
import com.huaxia.pojo.attend.SaleDeptAttend;
import com.huaxia.pojo.attend.SaleDeptLayerAttend;
import com.huaxia.pojo.deptLevels.*;
import com.huaxia.pojo.excellent.*;
import com.huaxia.pojo.goOn.BranchGoOn;
import com.huaxia.pojo.goOn.SaleDeptGoOn;
import com.huaxia.pojo.newAdd.BranchNewAdd;
import com.huaxia.pojo.newAdd.SaleDeptNewAdd;
import com.huaxia.pojo.performance.*;
import com.huaxia.pojo.product.BranchEvergreen;
import com.huaxia.pojo.product.BranchLuck;
import com.huaxia.pojo.product.SaleDeptEvergreen;
import com.huaxia.pojo.product.SaleDeptLuck;
import com.huaxia.pojo.promotion.*;
import com.huaxia.pojo.realAct.*;
import com.huaxia.service.SalesDataService;
import com.huaxia.service.attend.AttendService;
import com.huaxia.service.deptLevels.DeptLevelsService;
import com.huaxia.service.excellent.ExcellentService;
import com.huaxia.service.goOn.GoOnService;
import com.huaxia.service.newAdd.NewAddService;
import com.huaxia.service.performance.PerformanceService;
import com.huaxia.service.product.ProductService;
import com.huaxia.service.promotion.PromotionService;
import com.huaxia.service.realAct.RealActService;
import com.huaxia.service.update.UpdateYxAgentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;


import javax.servlet.ServletContext;
import java.util.List;

/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/06/03 16:06
 */
@Component
@Slf4j
public class CommonMethods {

    @Autowired
    private WebApplicationContext webApplicationContext;
    @Autowired
    private SalesDataService salesDataService;
    @Autowired
    private PerformanceService performanceService;
    @Autowired
    private AttendService attendService;
    @Autowired
    private NewAddService newAddService;
    @Autowired
    private RealActService realActService;
    @Autowired
    private PromotionService promotionService;
    @Autowired
    private ExcellentService excellentService;
    @Autowired
    private ProductService productService;
    @Autowired
    private GoOnService goOnService;
    @Autowired
    private DeptLevelsService deptLevelsService;
    @Autowired
    private UpdateYxAgentService updateYxAgentService;





    public void commonMethodsYxOne() {

        ServletContext servletContext = webApplicationContext.getServletContext();


        //更新人力
        updateYxAgentService.updateYxAgent();


        //首页
        SalesData salesData = salesDataService.getSalesData();
        servletContext.setAttribute("salesData", salesData);

        log.info("---------1,sales complete-------");

        //业绩(中支本月)
        List<BranchPerformance> branchPerformanceThisMon = performanceService.getBranchPerformanceThisMon();
        servletContext.setAttribute("branchPerformanceThisMon", branchPerformanceThisMon);

        //业绩(中支次月)
        List<BranchPerformance> branchPerformanceNextMon = performanceService.getBranchPerformanceNextMon();
        servletContext.setAttribute("branchPerformanceNextMon", branchPerformanceNextMon);

        //期交(中支本月)
        List<BranchLongPerformance> branchLongPerformanceThisMon = performanceService.getBranchLongPerformanceThisMon();
        servletContext.setAttribute("branchLongPerformanceThisMon", branchLongPerformanceThisMon);

        //期交(中支次月)
        List<BranchLongPerformance> branchLongPerformanceNextMon = performanceService.getBranchLongPerformanceNextMon();
        servletContext.setAttribute("branchLongPerformanceNextMon", branchLongPerformanceNextMon);

        //业绩(中支达成)
        List<BranchReach> branchReachs = performanceService.getBranchReach();
        servletContext.setAttribute("branchReachs", branchReachs);

        log.info("---------2,performance complete-------");



    }

    public void commonMethodsYxTwo() {

        ServletContext servletContext = webApplicationContext.getServletContext();

        //实动（中支）
        List<BranchMonthAct> branchMonthActs = realActService.getBranchThisMonthAct();
        servletContext.setAttribute("branchThisMonthActs", branchMonthActs);

        branchMonthActs = realActService.getBranchNextMonthAct();
        servletContext.setAttribute("branchNextMonthActs", branchMonthActs);

        List<BranchClassAct> branchClassActs = realActService.getBranchClassAct();
        servletContext.setAttribute("branchClassActs", branchClassActs);

        List<BranchBcAct> branchBcActs = realActService.getBranchBcAct();
        servletContext.setAttribute("branchBcActs", branchBcActs);

        List<BranchBmAct> branchBmActs = realActService.getBranchBmAct();
        servletContext.setAttribute("branchBmActs", branchBmActs);

        log.info("---------2,act1 complete-------");

        //业绩（营服）
        List<SaleDeptPerformance> saleDeptPerformances = performanceService.getSaleDeptPerformance();
        servletContext.setAttribute("saleDeptPerformances", saleDeptPerformances);

        List<SaleDeptLongPerformance> saleDeptLongPerformances = performanceService.getSaleDeptLongPerformance();
        servletContext.setAttribute("saleDeptLongPerformances", saleDeptLongPerformances);


        List<SaleDeptReach> saleDeptReachs = performanceService.getSaleDeptReach();
        servletContext.setAttribute("saleDeptReachs", saleDeptReachs);

        log.info("---------3,sales2 complete-------");


        //实动（营服）
        List<SaleDeptMonthAct> saleDeptMonthActs = realActService.getSaleDeptMonthAct();
        servletContext.setAttribute("saleDeptMonthActs", saleDeptMonthActs);

        List<SaleDeptClassAct> saleDeptClassActs = realActService.getSaleDeptClassAct();
        servletContext.setAttribute("saleDeptClassActs", saleDeptClassActs);

        List<SaleDeptBcAct> saleDeptBcActs = realActService.getSaleDeptBcAct();
        servletContext.setAttribute("saleDeptBcActs", saleDeptBcActs);

        List<SaleDeptBmAct> saleDeptBmActs = realActService.getSaleDeptBmAct();
        servletContext.setAttribute("saleDeptBmActs", saleDeptBmActs);

        log.info("---------4,act2 complete-------");

        //绩优
        List<BranchMDRT> branchMDRTs = excellentService.getBranchMDRT();
        servletContext.setAttribute("branchMDRTs", branchMDRTs);
        List<SaleDeptMDRT> saleDeptMDRTs = excellentService.getSaleDeptMDRT();
        servletContext.setAttribute("saleDeptMDRTs", saleDeptMDRTs);

        List<BranchFHS> branchFHSs = excellentService.getBranchFHS();
        servletContext.setAttribute("branchFHSs", branchFHSs);
        List<SaleDeptFHS> saleDeptFHSs = excellentService.getSaleDeptFHS();
        servletContext.setAttribute("saleDeptFHSs", saleDeptFHSs);

        List<BranchQuarterFHS> branchQuarterFHSs = excellentService.getBranchQuarterFHS();
        servletContext.setAttribute("branchQuarterFHSs", branchQuarterFHSs);
        List<SaleDeptQuarterFHS> saleDeptQuarterFHSs = excellentService.getSaleDeptQuarterFHS();
        servletContext.setAttribute("saleDeptQuarterFHSs", saleDeptQuarterFHSs);

        log.info("---------5,MDRT complete-------");

        //新增
        List<BranchNewAdd> branchNewAdds = newAddService.getBranchNewAdd();
        servletContext.setAttribute("branchNewAdds", branchNewAdds);

        List<SaleDeptNewAdd> saleDeptNewAdds = newAddService.getSaleDeptNewAdd();
        servletContext.setAttribute("saleDeptNewAdds", saleDeptNewAdds);

        log.info("---------6,add complete-------");

        //晋升
        List<BranchBC> branchBCs = promotionService.getBranchBC();
        servletContext.setAttribute("branchBCs", branchBCs);
        List<BranchSBC> branchSBCs = promotionService.getBranchSBC();
        servletContext.setAttribute("branchSBCs", branchSBCs);
        List<BranchBM> branchBMs = promotionService.getBranchBM();
        servletContext.setAttribute("branchBMs", branchBMs);
        List<BranchSBM> branchSBMs = promotionService.getBranchSBM();
        servletContext.setAttribute("branchSBMs", branchSBMs);
        List<BranchAS> branchASs = promotionService.getBranchAS();
        servletContext.setAttribute("branchASs", branchASs);

        List<SaleDeptBC> saleDeptBCs = promotionService.getSaleDeptBC();
        servletContext.setAttribute("saleDeptBCs", saleDeptBCs);
        List<SaleDeptSBC> saleDeptSBCs = promotionService.getSaleDeptSBC();
        servletContext.setAttribute("saleDeptSBCs", saleDeptSBCs);
        List<SaleDeptBM> saleDeptBMs = promotionService.getSaleDeptBM();
        servletContext.setAttribute("saleDeptBMs", saleDeptBMs);
        List<SaleDeptSBM> saleDeptSBMs = promotionService.getSaleDeptSBM();
        servletContext.setAttribute("saleDeptSBMs", saleDeptSBMs);
        List<SaleDeptAS> saleDeptASs = promotionService.getSaleDeptAS();
        servletContext.setAttribute("saleDeptASs", saleDeptASs);

        log.info("---------7,promotion complete-------");


        //产品
        List<BranchEvergreen> branchEvergreens = productService.getBranchEvergreen();
        servletContext.setAttribute("branchEvergreens", branchEvergreens);
        List<BranchLuck> branchLucks = productService.getBranchLuck();
        servletContext.setAttribute("branchLucks", branchLucks);
        List<SaleDeptEvergreen> saleDeptEvergreens = productService.getSaleDeptEvergreen();
        servletContext.setAttribute("saleDeptEvergreens", saleDeptEvergreens);
        List<SaleDeptLuck> saleDeptLucks = productService.getSaleDeptLuck();
        servletContext.setAttribute("saleDeptLucks", saleDeptLucks);

        log.info("---------8,product complete-------");

        //收展
        List<SzPerformance> szPerformances = performanceService.getSzPerformance();
        servletContext.setAttribute("szPerformances", szPerformances);
        List<SzLongPerformance> szlongPerformances = performanceService.getSzLongPerformance();
        servletContext.setAttribute("szLongPerformances", szlongPerformances);
        List<SzMonthAct> szMonthActs = realActService.getSzMonthAct();
        servletContext.setAttribute("szMonthActs", szMonthActs);
        List<SzFHS> szFHSs = excellentService.getSzFHS();
        servletContext.setAttribute("szFHSs", szFHSs);
        log.info("---------9,SZ complete-------");
    }


    public void commonMethodsYxThree() {

        ServletContext servletContext = webApplicationContext.getServletContext();

        //继续率
        List<BranchGoOn> branchGoOns13 = goOnService.getBranchGoOn13();
        servletContext.setAttribute("branchGoOns13", branchGoOns13);

        List<SaleDeptGoOn> saleDeptGoOns13 = goOnService.getSaleDeptGoOn13();
        servletContext.setAttribute("saleDeptGoOns13", saleDeptGoOns13);

        List<BranchGoOn> branchGoOns25 = goOnService.getBranchGoOn25();
        servletContext.setAttribute("branchGoOns25", branchGoOns25);

        List<SaleDeptGoOn> saleDeptGoOns25 = goOnService.getSaleDeptGoOn25();
        servletContext.setAttribute("saleDeptGoOns25", saleDeptGoOns25);

        log.info("---------10,goOn complete-------");

        //出勤
        List<BranchAttend> branchAttends = attendService.getBranchAttend();
        servletContext.setAttribute("branchAttends", branchAttends);

        List<SaleDeptAttend> saleDeptAttends = attendService.getSaleDeptAttend();
        servletContext.setAttribute("saleDeptAttends", saleDeptAttends);

        List<BranchLayerAttend> branchLayerAttends = attendService.getBranchLayerAttend();
        servletContext.setAttribute("branchLayerAttends", branchLayerAttends);

        List<SaleDeptLayerAttend> saleDeptLayerAttends = attendService.getSaleDeptLayerAttend();
        servletContext.setAttribute("saleDeptLayerAttends", saleDeptLayerAttends);

        log.info("---------11,attend complete-------");

        //标准部组
        List<DeptAS> deptASs = deptLevelsService.getDeptAS();
        servletContext.setAttribute("deptASs", deptASs);
        List<DeptBM> deptBMs = deptLevelsService.getDeptBM();
        servletContext.setAttribute("deptBMs", deptBMs);
        List<DeptBC> deptBCs = deptLevelsService.getDeptBC();
        servletContext.setAttribute("deptBCs", deptBCs);
        List<BranchStandard> branchStandards = deptLevelsService.getBranchStandard();
        servletContext.setAttribute("branchStandards", branchStandards);
        List<SaleDeptStandard> saleDeptStandards = deptLevelsService.getSaleDeptStandard();
        servletContext.setAttribute("saleDeptStandards", saleDeptStandards);

        log.info("---------yx methods complete-------");

    }

}
